import java.util.Scanner;
import java.util.Random;

/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: 87111
 * Date: 2025-05-11
 * Time: 14:00
 */
public class test {
    public static void main(String[] args) {
        //猜数字游戏
        Scanner sc = new Scanner(System.in);
        Random ran = new Random();//种子是系统时间
        int b = ran.nextInt(100);//生成伪随机数范围[0,100);
        while(true){
            System.out.println("请输入你要猜的数字：");
            int a = sc.nextInt();
            if(a > b){
                System.out.println("猜大了");
            }else if(a < b){
                System.out.println("猜小了");
            }else{
                System.out.println("猜对了");
                break;
            }
        }
    }
    public static void main7(String[] args) {
        //求一个整数，在内存当中存储时，二进制1的个数。
        //方法一：
//        Scanner sc = new Scanner(System.in);
//        int a = sc.nextInt();
//        int sum = 0;
//        while(a > 0){
//            if((a&1) == 1){
//                sum++;
//            }
//            a >>>= 1;
//        }
//        System.out.println(sum);
        //方法二：(原理：假设一个变量a,a&(a-1)后在内存中存储的二进制中1数量少一个）
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        int count = 0;
        while(a != 0){
            a = a & (a-1);
            count++;
        }
        System.out.println(count);
    }
    public static void main6(String[] args) {
        //求2个整数的最大公约数
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        int b = sc.nextInt();
        int c = 0;
        while(b > 0){
            c = a;
            a = b;
            b = c % b;
        }
        System.out.println(a);
    }
    public static void main5(String[] args) {
        //计算1/1-1/2+1/3-1/4+1/5 …… + 1/99 - 1/100 的值
        float sum = 0;
        float a = 1.0F;
        for (int i = 1; i <= 100; i++) {
            sum += a/i;
            a = -a;
        }
        System.out.println(sum);
    }
    public static void main4(String[] args) {
        //求出0～n之间的所有“水仙花数”并输出,“水仙花数”是指一个三位数
        Scanner sc = new Scanner(System.in);
        int n =sc.nextInt();
        for (int i = 0; i < n; i++) {
            int count = 0;
            int a = i;
            int sum = 0;
            //判断位数
            while(a>0){
                if(a % 10 != 0){
                    count++;
                }
                a /= 10;
            }
            a = i;
            //判断水仙花数
            while(a>0){
                sum += Math.pow(a % 10,count);
                a /= 10;
            }
            if(sum == i){
                System.out.println(i);
            }
        }
    }
    public static void main3(String[] args) {
        //打印X图形
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        for (int i = 0; i < a; i++) {
            for (int j = 0; j < a; j++) {
                if((i == j)||(i+j+1 == a)){
                    System.out.print('*');
                }else{
                    System.out.print(' ');
                }
            }
            System.out.println();
        }
    }
    public static void main2(String[] args) {
        //给定一个数字，判定一个数字是否是素数
        //法一：
//        Scanner scanner = new Scanner(System.in);
//        int a = scanner.nextInt();
//        boolean b = true;
//        for (int i = 2; i < a; i++) {
//            if(a % i == 0) {
//                System.out.println("不是素数");
//                b = false;
//                break;
//            }
//        }
//        if(b == true){
//            System.out.println("是素数");
//        }
        //法二：
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        int i = 0;
        for (i = 2; i <= Math.sqrt(a); i++) {
            if((a % i) == 0){
                System.out.println(a+"不是素数");
                break;
            }
        }
        if(i > Math.sqrt(a)){
            System.out.println(a+"是素数");
        }
    }

    public static void main1(String[] args) {
        //编写程序数一下 1到 100 的所有整数中出现多少个数字9
        int a = 1;
        int sum = 0;
        while (a <= 100) {
            if (a % 10 == 9) {
                sum++;
            }
            if(a / 10 == 9){
                sum++;
            }
            a++;
        }
        System.out.println(sum);
    }
}
